package Decorator;

use JIP::ToolSet; # load my commonly-used modules in a single import
use vars qw( $METHOD $AUTOLOAD );
use parent qw( Class::Accessor::Fast );
use English qw( -no_match_vars );
use Carp qw( croak );

__PACKAGE__->mk_ro_accessors( qw( component ) );

sub new {
    my( $class, $component ) = @ARG;

    my $self = bless { component => $component }, $class;

    return $self;
}

sub AUTOLOAD {
    my( $self, @args ) = @ARG;

    if ( $AUTOLOAD =~ /.+::(.+)$/ ) {
        $METHOD = $1;
    }
    else {
        croak "cannot find method name";
    }

    $self->component->$METHOD( @args );
}

sub DESTROY {}

1;
